package com.olocat.cjx.nsims.dao

import com.olocat.cjx.nsims.pojo.notice.Notice
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Modifying
import org.springframework.data.jpa.repository.Query
import javax.transaction.Transactional

interface NoticeRepository : JpaRepository<Notice, String> {
    fun getNoticesByUserId(userId: String) : List<Notice>
    fun countNoticesByUserIdAndStateEquals(userId: String, state: Boolean) : Int
    @Transactional
    @Modifying
    @Query("update Notice n set n.state = ?2 where n.id = ?1")
    fun updateStateById(id: String, state: Boolean)
}